<template>
  <!-- 动态加载配置 -->
  <el-card :body-style="{ padding: '10px 0' }" style="border: none">
    <el-empty v-if="!dynamicComponentConfig" description="暂无选中组件" />

    <template v-else>
      <component
        :is="dynamicComponentConfig"
        v-bind="{ ...$attrs, ...$props }"
        v-on="$listeners"
      />

      <!-- 公共配置 -->
      <DynamicConfigCommon />
    </template>
  </el-card>
</template>

<script>
import widget from '@/mixins/widget'
import Widgets from '@/components/Widgets'
import DynamicConfigCommon from '@/components/Widgets/DynamicConfigCommon'

export default {
  mixins: [widget],
  components: {
    DynamicConfigCommon
  },

  computed: {
    dynamicComponentConfig() {
      if (this.selectWidget.type) {
        return Widgets[this.selectWidget.type]['Config']
      } else {
        return false
      }
    }
  }
}
</script>

<style lang="scss" scoped></style>
